package com.actimize.model;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;


import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;

	/**
	 */
	@Entity
	@Table(name = "trans")
	@Indexed
	@XmlRootElement
	public class Transaction extends BaseObject implements Serializable {
	    private static final long serialVersionUID = 32359421L;

	    private Long tranId;
	    private String tranDate;                    // required
	    private String tranDesc;                    // required
	    private String tranType;
	    private Double tranIn;
	    private Double tranOut;

	    /**
	     * Default constructor - creates a new instance with no values set.
	     */
	    public Transaction() {
	    }

	    public Transaction(final Long tranId) {
	        this.tranId = tranId;
	    }

	    @Id
	    @GeneratedValue(strategy = GenerationType.AUTO)
	    @DocumentId
	    public Long getTranId() {
	        return tranId;
	    }

	    
	    @Column(name = "tranDate", nullable = false)
	    @Field
	    public String getTranDate() {
	        return tranDate;
	    }

	    @Column(name = "tranDesc")
	    @Field
	    public String getTranDesc() {
	        return tranDesc;
	    }

	    @Column(name = "tranType")
	    @Field
	    public String getTranType() {
	        return tranType;
	    }
	    @Column(name = "tranIn")
	    @Field
	    public Double getTranIn() {
	        return tranIn;
	    }
	    @Column(name = "tranOut")
	    @Field
	    public Double getTranOut() {
	        return tranOut;
	    }


	    public void setTranId(Long tranId) {
	        this.tranId = tranId;
	    }

	    public void setTranDate(String tranDate) {
	        this.tranDate = tranDate;
	    }

	    public void setTranDesc(String tranDesc) {
	        this.tranDesc = tranDesc;
	    }

	    public void setTranType(String tranType) {
	        this.tranType = tranType;
	    }

	    public void setTranIn(Double tranIn) {
	        this.tranIn = tranIn;
	    }

	    public void setTranOut(double tranOut) {
	        this.tranOut = tranOut;
	    }
	    
	    /**
	     * {@inheritDoc}
	     */
	    public boolean equals(Object o) {
	        if (this == o) {
	            return true;
	        }
	        if (!(o instanceof Transaction)) {
	            return false;
	        }

	        final Transaction tran = (Transaction) o;

	        return !(tranId != null ? !tranId.equals(tran.getTranId()) : tran.getTranId() != null);

	    }

	    /**
	     * {@inheritDoc}
	     */
	    public int hashCode() {
	        return (tranId + tranDesc != null ? (tranId + tranDesc).hashCode() : 0);
	    }

	    /**
	     * {@inheritDoc}
	     */
	    public String toString() {
	        ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
	                .append("tranId", this.tranId)
	                .append("tranDesc", this.tranDesc)
	                .append("tranIn", this.tranIn)
	                .append("tranOut", this.tranOut);

	        return sb.toString();
	    }
	}
